package NG::Gen::Users::Achievement;
use strict;
use warnings;
use utf8;

use NG::Sys::Datetime;

sub achievement_list {
	my $self = shift;
	return $self->achievement->get_list;
}
sub count_achievement {
	my $self = shift;
	my $name = shift;
	my $value = shift || 1;
	my $ref = $self->{parent}{app}->reference("achievement")->get_by_index($name);
	my $pos = $ref->{levels};
	unless($ref){
		die "bad achievement count '$name'";
	}
	my $current = $self->achievement->get_row($name);
	
	if($ref->{type} == 1){
		unless($current){
			$current->{
				start => unixtime2timestamp(),
				value => $value,
			};
		}
	}
	elsif($ref->{type} == 2){
		unless($current){
			$current->{
				start => unixtime2timestamp(),
				value => 
			};
		}
	}
}

1;
